//
//  ViewController.m
//  TabBar
//
//  Created by 温人米 on 2019/1/9.
//  Copyright © 2019年 温人米. All rights reserved.
//

#import "ViewController.h"

#define screenW [UIScreen mainScreen].bounds.size.width

@interface ViewController ()
@property (nonatomic, strong)UIButton *buttonBlack;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor grayColor];
    self.buttonBlack.frame = CGRectMake(0, 20, 44, 44);
}

-(UIButton *)buttonBlack{
    if (!_buttonBlack) {
        _buttonBlack = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [self.viewTop addSubview:_buttonBlack];
        [_buttonBlack setImage:[UIImage imageNamed:@"work_arrow-white"] forState:(UIControlStateNormal)];
        [_buttonBlack addTarget:self action:@selector(buttonBlackClick:) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _buttonBlack;
}

-(void)buttonBlackClick:(UIButton *)btn{
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)setTitle:(NSString *)Title{
    _Title = Title;
    
    self.labelTitle.text = Title;
    CGSize size = [self.labelTitle sizeThatFits:CGSizeMake(screenW - 40, 44)];
    self.labelTitle.frame = CGRectMake((screenW - size.width) / 2, 20, size.width, 44);
}

-(UILabel *)labelTitle{
    if (!_labelTitle) {
        _labelTitle = [[UILabel alloc] init];
        _labelTitle.textColor = [UIColor blackColor];
        _labelTitle.font = [UIFont systemFontOfSize:14.f];
        [self.viewTop addSubview:_labelTitle];
    }
    return _labelTitle;
}

-(UIView *)viewTop{
    if (!_viewTop) {
        _viewTop = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenW, 64)];
        _viewTop.backgroundColor = [UIColor orangeColor];
        [self.view addSubview:_viewTop];
    }
    return _viewTop;
}



@end
